# -*- coding: utf-8 -*-
# @Time : 2022-05-23 10:59
# @Author : Z
# @Function : qq

# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python

# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python
import time

from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy


# 配置信息
caps = {}
caps["platformName"] = "Android"
caps["platformVersion"] = "7.1.2"
caps["deviceName"] = "127.0.0.1:62001"
caps["appPackage"] = "com.tencent.mobileqq"
caps["appActivity"] = ".activity.SplashActivity"
caps["noReset"] = "true"

# 连接appium
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
driver.implicitly_wait(10)

# 登陆
el1 = driver.find_element(AppiumBy.ACCESSIBILITY_ID,"请输入QQ号码或手机或邮箱")
el1.send_keys("2707630641")
el2 = driver.find_element(AppiumBy.ACCESSIBILITY_ID,"密码 安全")
el2.clear()
el2.click()
el2.send_keys("7812977zwx")
el3 = driver.find_element(AppiumBy.ACCESSIBILITY_ID,"登 录")
el3.click()
time.sleep(1)
# driver.save_screenshot("login.png")
# driver.get_screenshot_as_file(path+r"\lib\imgs\test.png")

# 退出登陆
els1 = driver.find_element(AppiumBy.ACCESSIBILITY_ID,"帐户及设置")
els1.click()
els2 = driver.find_element(AppiumBy.ACCESSIBILITY_ID,"设置")
els2.click()
els3 = driver.find_element(AppiumBy.ACCESSIBILITY_ID,"帐号管理")
els3.click()
els4 = driver.find_element(AppiumBy.ACCESSIBILITY_ID,"退出当前帐号按钮")
els4.click()
els5 = driver.find_element(AppiumBy.XPATH, "//*[@text=\"退出登录\"]")
els5.click()
els6 = driver.find_element(AppiumBy.XPATH, "//*[@text=\"确定退出\"]")
els6.click()

driver.quit()
